asm
  ld sp,$FFFF
  end asm

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"

dim eee as uinteger at $E010
dim seed as uinteger at $E012
dim ee0 as uinteger at $E014
dim ee1 as uinteger at $E016
dim ee2 as uinteger at $E018
dim ee3 as uinteger at $E01A
dim eex as uinteger at $E01C
dim eey as uinteger at $E01E

sub shisenputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte):
  poke $D000+(txp1*2)+(typ1*128),tch1
  poke $D001+(txp1*2)+(typ1*128),tat1
  end sub

seed=22974

for eee=$C800 to $CAFF '- palette
  seed=smsrnd(seed)
  poke eee,seed
  next

for ee0=0 to 31
  for ee1=0 to 63
    seed=smsrnd(seed)
    ee2=seed
    seed=smsrnd(seed)
    shisenputchar(ee1,ee0,seed band 15,ee2 band 240)
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    shisenputchar(ee1+47,ee0+15,ee0*16+ee1,16)
    next:next

eex=8:eey=8
eee=0
do

shisenputchar(1,1,48+(int(eee/100) mod 10),16)
shisenputchar(2,1,48+(int(eee/10) mod 10),16)
shisenputchar(3,1,48+(eee mod 10),16)

ee0=in($00) bxor $FF
shisenputchar(1,3,48+(int(ee0/100) mod 10),16)
shisenputchar(2,3,48+(int(ee0/10) mod 10),16)
shisenputchar(3,3,48+(ee0 mod 10),16)

ee0=in($01) bxor $FF
shisenputchar(1,4,48+(int(ee0/100) mod 10),16)
shisenputchar(2,4,48+(int(ee0/10) mod 10),16)
shisenputchar(3,4,48+(ee0 mod 10),16)

ee0=in($02) bxor $FF
shisenputchar(1,5,48+(int(ee0/100) mod 10),16)
shisenputchar(2,5,48+(int(ee0/10) mod 10),16)
shisenputchar(3,5,48+(ee0 mod 10),16)

eey=eey-((ee0 band 1)/1)+((ee0 band 2)/2)
eex=eex-((ee0 band 4)/4)+((ee0 band 8)/8)



ee0=in($03) bxor $FF
shisenputchar(1,6,48+(int(ee0/100) mod 10),16)
shisenputchar(2,6,48+(int(ee0/10) mod 10),16)
shisenputchar(3,6,48+(ee0 mod 10),16)



shisenputchar(eex,eey,eee mod 128,16)

eee=eee+1
loop

do:loop









do

for eee=$C800 to $CAFF '- palette
  seed=smsrnd(seed)
  poke eee,seed
  next


for eee=$D000 to $DFFF step 2 '- video
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next

for eee=$D001 to $DFFF step 2 '- video
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next



loop



'- static ADDRESS_MAP_START( shisen_map, AS_PROGRAM, 8, shisen_state )
'- AM_RANGE(0x0000, 0x7fff) AM_ROM
'- AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
'- AM_RANGE(0xc800, 0xcaff) AM_RAM_WRITE(paletteram_w) AM_SHARE("paletteram")
'- AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(videoram_w) AM_SHARE("videoram")
'- AM_RANGE(0xe000, 0xffff) AM_RAM
'- ADDRESS_MAP_END

'- static ADDRESS_MAP_START( shisen_io_map, AS_IO, 8, shisen_state )
'- ADDRESS_MAP_GLOBAL_MASK(0xff)
'- AM_RANGE(0x00, 0x00) AM_READWRITE(dsw1_r, coin_w)
'- AM_RANGE(0x01, 0x01) AM_READ_PORT("DSW2") AM_DEVWRITE("m72", m72_audio_device, sound_command_byte_w)
'- AM_RANGE(0x02, 0x02) AM_READ_PORT("P1") AM_WRITE(bankswitch_w)
'- AM_RANGE(0x03, 0x03) AM_READ_PORT("P2")
'- AM_RANGE(0x04, 0x04) AM_READ_PORT("COIN")
'- ADDRESS_MAP_END
